import { PrismaClient } from "../src/generated/prisma/client.js";

<% if (addOnOption.prisma.database === 'postgres') { %>
import { PrismaPg } from '@prisma/adapter-pg';

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL!,
});<% } %>

<% if (addOnOption.prisma.database === 'mysql') { %>
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
const adapter = new PrismaMariaDb({
  host: "localhost",
  port: 3306,
  connectionLimit: 5
});<% } %>

<% if (addOnOption.prisma.database === 'sqlite') { %>
import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3';
const adapter = new PrismaBetterSQLite3({
  url: process.env.DATABASE_URL || 'file:./dev.db'
});<% } %>

const prisma = new PrismaClient({adapter})

async function main() {
  console.log('🌱 Seeding database...')

  // Clear existing todos
  await prisma.todo.deleteMany()

  // Create example todos
  const todos = await prisma.todo.createMany({
    data: [
      { title: 'Buy groceries' },
      { title: 'Read a book' },
      { title: 'Workout' },
    ],
  })

  console.log(`✅ Created ${todos.count} todos`)
}

main()
  .catch((e) => {
    console.error('❌ Error seeding database:', e)
    process.exit(1)
  })
  .finally(async () => {
    await prisma.$disconnect()
  })
